<template>
  <div
    class="user-cell"
    :class="cellClass"
  >
    <div
      class="user-cell-image"
      v-if="icon"
    >
      <image
        :src="icon"
        mode="aspectFill"
      />
    </div>
    <div class="user-cell-content">
      <div class="user-cell-title">{{title}}</div>
      <div class="user-cell-label">{{label}}</div>
    </div>
    <div class="user-cell-extend">
      <slot />
    </div>
  </div>
</template>

<script>
export default {
  name: 'UserCell',
  props: {
    customClass: String,
    title: String,
    icon: String,
    label: String,
    border: {
      type: Boolean,
      default: true
    },
    size: {
      type: String,
      default: 'normal'
    },
    align: {
      type: String,
      default: 'center'
    },
    gutter: [Number, String],
    background: String,
    iconWidth: [Number, String],
    iconHeight: [Number, String]
  },
  computed: {
    cellClass () {
      let classes = []
      if (this.align) {
        classes.push('user-cell--' + this.align)
      }
      if (this.size) {
        classes.push('user-cell--' + this.size)
      }
      if (this.customClass) {
        classes.push(this.customClass)
      }
      if (this.border) {
        classes.push('van-hairline--top-bottom')
      }
      return classes
    }
  },
  methods: {

  }
}
</script>

<style lang="less" scoped>
.van-cell-group {
  > .user-cell {
    padding: 10px 15px;
  }
}
.user-cell {
  padding: 10px 0;
  display: flex;
  justify-content: space-around;
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 15px;
  &::after {
    border-radius: 5px;
  }
  &:last-child {
    margin: 0;
  }
  &-image {
    margin-right: 10px;
    display: flex;
    image {
      width: 40px;
      height: 40px;
      border-radius: 50%;
    }
  }
  &--center {
    align-items: center;
    .user-cell-image {
      align-items: center;
    }
  }
  &--bottom {
    align-items: flex-end;
    .user-cell-image {
      align-items: flex-end;
    }
  }
  &--large {
    .user-cell-image {
      image {
        width: 50px;
        height: 50px;
      }
    }
  }
  &-content {
    flex: 1;
    display: flex;
    flex-direction: column;
  }
  &-title {
    font-size: 14px;
    font-weight: bold;
  }
  &-label {
    font-size: 12px;
    opacity: 0.6;
  }
}
</style>
